<template>
    <div class="content">
        <div class="infinite-list-wrapper" style="overflow: auto">
        <ul
            v-infinite-scroll="load"
            class="list"
            :infinite-scroll-disabled="disabled"
        >
            <li v-for="i in count" :key="i" class="list-item">{{ i }}</li>
        </ul>
        <p v-if="loading">加载中...</p>
        <p v-if="noMore">没有更多了</p>
  </div>
    </div>
</template>

<script lang="ts" setup>
    import { ref, reactive, markRaw, onBeforeMount, onMounted, onBeforeUnmount, nextTick, computed  } from 'vue'
    import type { Ref, Raw } from 'vue'

    const count = ref(10)
    const loading = ref(false)
    const noMore = computed(() => count.value >= 20)
    const disabled = computed(() => loading.value || noMore.value)
    const load = () => {
        console.log('1')
        loading.value = true
        setTimeout(() => {
            count.value += 2
            loading.value = false
        }, 2000)
    }
    
</script>

<style lang="scss" scoped>
    .content::after {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        z-index: -1;
        width: 100vw;
        height: 100vh;
        background-image: url('@/assets/avatar/bg8.png');
        background-size: 100% 100%;
        filter: blur(5px);
    }
    .content {
        width: 100vw;
        height: 100vh;
        // background-image: url('@/assets/avatar/bg7.png');
        // background-size: 100% 100%;
        overflow: hidden;
        // display: flex;
        color: #fff;
        box-sizing: border-box;
    }
    .infinite-list-wrapper {
        height: 300px;
        // height: 100vh;
        text-align: center;
    }
    .infinite-list-wrapper .list {
        padding: 0;
        margin: 0;
        list-style: none;
    }

    .infinite-list-wrapper .list-item {
        display: flex;
        align-items: center;
        justify-content: center;
        height: 50px;
        background: var(--el-color-danger-light-9);
        color: var(--el-color-danger);
    }
    .infinite-list-wrapper .list-item + .list-item {
        margin-top: 10px;
    }
</style>